package com.example.security.config;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

/**
 * jwt工具类
 */
public class JwtUtil {

    private final static String secret="jwtsecrity";
    private final static String issUser="wangkai";


    /**
     *
     * @param account
     * @return
     */
    public static String token(String  account){
        String token = Jwts.builder()
                .setSubject(account)
                .setIssuer(issUser)
                .signWith(SignatureAlgorithm.HS512, secret).compact();
        return token;
    }


    /**
     *
     * @param token
     * @return
     */
   public static Claims getClaim(String token){
    return Jwts.parser()
               .requireIssuer(issUser)
               .setSigningKey(secret)
               .parseClaimsJws(token)
               .getBody();
   }


}
